#ifndef COM_CONTROL_WIDGET_H
#define COM_CONTROL_WIDGET_H

#include <QWidget>
#include <QByteArray>

class QSerialPort;

namespace Ui {
class ComCtrlWidget;
}

class ComCtrlWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ComCtrlWidget(QWidget *parent = nullptr);
    ~ComCtrlWidget();

signals:
    void openPortSuccess();
    void openPortFailed();
    void closePortSuccess();

    void debugMessage(const QString &text);
    void dataReceived(const QByteArray &data);

public slots:
    void openPort();
    void closePort();
    void sendData(const QByteArray &data);

private slots:
    void onReceiveData();

    void on_btnRefresh_clicked();

    void on_btnOpen_clicked();

    void on_btnClose_clicked();

private:
    Ui::ComCtrlWidget *ui;

    QSerialPort *p_serialPort ;
};

#endif // COM_CONTROL_WIDGET_H
